VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MsComCtl.ocx"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmGLCredit 
   BackColor       =   &H00F7D9C2&
   BorderStyle     =   0  'None
   Caption         =   "Form1"
   ClientHeight    =   7260
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   10635
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   7260
   ScaleWidth      =   10635
   ShowInTaskbar   =   0   'False
   Begin ITGControls.ITGTab SSTab1 
      Height          =   3465
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   10500
      _ExtentX        =   18521
      _ExtentY        =   6112
      TabCount        =   2
      TabCaption(0)   =   "               Main               "
      TabContCtrlCnt(0)=   1
      Tab(0)ContCtrlCap(1)=   "ComunionFrames1"
      TabCaption(1)   =   "               List               "
      TabContCtrlCnt(1)=   1
      Tab(1)ContCtrlCap(1)=   "dtgList"
      TabTheme        =   2
      ActiveTabBackStartColor=   16250865
      ActiveTabBackEndColor=   16243138
      InActiveTabBackStartColor=   16243138
      InActiveTabBackEndColor=   16243138
      InActiveTabForeColor=   0
      BeginProperty ActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty InActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      OuterBorderColor=   4210752
      TopLeftInnerBorderColor=   4210752
      BottomRightInnerBorderColor=   4210752
      DisabledTabBackColor=   16243138
      DisabledTabForeColor=   -2147483630
      Begin MSDataGridLib.DataGrid dtgList 
         Height          =   3150
         Left            =   -75000
         TabIndex        =   19
         Top             =   315
         Width           =   10500
         _ExtentX        =   18521
         _ExtentY        =   5556
         _Version        =   393216
         AllowUpdate     =   0   'False
         AllowArrows     =   -1  'True
         Appearance      =   0
         HeadLines       =   1
         RowHeight       =   15
         TabAcrossSplits =   -1  'True
         TabAction       =   2
         FormatLocked    =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   6
         BeginProperty Column00 
            DataField       =   "cTranNo"
            Caption         =   "Transaction No."
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   "dDate"
            Caption         =   "Date"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   3
            EndProperty
         EndProperty
         BeginProperty Column02 
            DataField       =   "cBankID"
            Caption         =   "Bank Code"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column03 
            DataField       =   "cTranType"
            Caption         =   "Type"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column04 
            DataField       =   "nGross"
            Caption         =   "Gross"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column05 
            DataField       =   "cRemarks"
            Caption         =   "Remarks"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            AllowRowSizing  =   0   'False
            BeginProperty Column00 
               Locked          =   -1  'True
               ColumnWidth     =   1725.165
            EndProperty
            BeginProperty Column01 
               Locked          =   -1  'True
               ColumnWidth     =   1170.142
            EndProperty
            BeginProperty Column02 
               Locked          =   -1  'True
               ColumnWidth     =   1484.787
            EndProperty
            BeginProperty Column03 
               Locked          =   -1  'True
            EndProperty
            BeginProperty Column04 
               Alignment       =   1
               Locked          =   -1  'True
            EndProperty
            BeginProperty Column05 
               Locked          =   -1  'True
               ColumnWidth     =   3179.906
            EndProperty
         EndProperty
      End
      Begin ITGControls.ComunionFrames ComunionFrames1 
         Height          =   3150
         Left            =   0
         Top             =   315
         Width           =   10500
         _ExtentX        =   18521
         _ExtentY        =   5556
         FrameColor      =   4210752
         BackColor       =   16243138
         FillColor       =   16243138
         RoundedCorner   =   0   'False
         Caption         =   "Transaction Information"
         Alignment       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ThemeColor      =   5
         ColorFrom       =   16243138
         ColorTo         =   16250865
         Begin VB.Frame Frame2 
            BackColor       =   &H00F7D9C2&
            Caption         =   "Legend:"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   2040
            Left            =   7125
            TabIndex        =   11
            Top             =   870
            Width           =   2865
            Begin VB.Label Label12 
               BackColor       =   &H00F7D9C2&
               Caption         =   "ADP   Asset Disposal"
               Height          =   255
               Left            =   435
               TabIndex        =   18
               Top             =   1680
               Width           =   1755
            End
            Begin VB.Label Label11 
               BackColor       =   &H00F7D9C2&
               Caption         =   "EXP   Interest Expense"
               Height          =   195
               Left            =   435
               TabIndex        =   17
               Top             =   1440
               Width           =   1875
            End
            Begin VB.Label Label10 
               BackColor       =   &H00F7D9C2&
               Caption         =   "INT   Interest Income"
               Height          =   255
               Left            =   435
               TabIndex        =   16
               Top             =   1200
               Width           =   1755
            End
            Begin VB.Label Label9 
               BackColor       =   &H00F7D9C2&
               Caption         =   "LRL    Loan Release"
               Height          =   255
               Left            =   435
               TabIndex        =   15
               Top             =   960
               Width           =   1875
            End
            Begin VB.Label Label6 
               BackColor       =   &H00F7D9C2&
               Caption         =   "AVM   TD Reavailment"
               Height          =   255
               Left            =   435
               TabIndex        =   14
               Top             =   720
               Width           =   1635
            End
            Begin VB.Label Label5 
               BackColor       =   &H00F7D9C2&
               Caption         =   "TTD   TD Termination"
               Height          =   255
               Left            =   435
               TabIndex        =   13
               Top             =   480
               Width           =   1695
            End
            Begin VB.Label Label1 
               BackColor       =   &H00F7D9C2&
               Caption         =   "CRM  Credit Entry"
               Height          =   255
               Left            =   435
               TabIndex        =   12
               Top             =   240
               Width           =   1335
            End
         End
         Begin VB.CommandButton cmdPickClient 
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   2670
            Picture         =   "frmGLCredit.frx":0000
            Style           =   1  'Graphical
            TabIndex        =   5
            Top             =   870
            Width           =   315
         End
         Begin VB.Timer Timer1 
            Interval        =   300
            Left            =   3240
            Top             =   300
         End
         Begin ITGControls.ITGTextBox txtName 
            Height          =   285
            Left            =   3000
            TabIndex        =   7
            Top             =   870
            Width           =   3825
            _ExtentX        =   6641
            _ExtentY        =   503
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "ITGtext"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   3765
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtCode 
            Height          =   285
            Left            =   195
            TabIndex        =   4
            Top             =   870
            Width           =   2445
            _ExtentX        =   4101
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "Bank Code"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1135
            Required        =   -1  'True
         End
         Begin ITGControls.ITGTextBox txtRemarks 
            Height          =   285
            Left            =   195
            TabIndex        =   6
            Top             =   1185
            Width           =   6630
            _ExtentX        =   11483
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "Remarks"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   5320
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox txtGross 
            Height          =   285
            Left            =   4335
            TabIndex        =   8
            Top             =   1500
            Width           =   2490
            _ExtentX        =   4180
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Amount"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1000
            TextBoxWidth    =   1430
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGDateBox dtbDate 
            Height          =   285
            Left            =   5505
            TabIndex        =   2
            Tag             =   "Transaction Date"
            Top             =   555
            Width           =   1320
            _ExtentX        =   2328
            _ExtentY        =   503
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   ""
            SendKeysTab     =   -1  'True
            Mandatory       =   -1  'True
         End
         Begin ITGControls.ITGTextBox txtTranNo 
            Height          =   285
            Left            =   180
            TabIndex        =   1
            Top             =   555
            Width           =   2460
            _ExtentX        =   4128
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "Transaction No."
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1150
            Required        =   -1  'True
         End
         Begin ITGControls.ITGTextBox txtType 
            Height          =   285
            Left            =   7080
            TabIndex        =   3
            Tag             =   "cboType"
            Top             =   555
            Visible         =   0   'False
            Width           =   1140
            _ExtentX        =   1905
            _ExtentY        =   503
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Mandatory       =   -1  'True
            Label           =   "Transaction Type"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   1080
            LinkForeColor   =   0
         End
         Begin VB.Label Label2 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "Date"
            Height          =   195
            Left            =   4995
            TabIndex        =   9
            Top             =   555
            Width           =   345
         End
      End
   End
   Begin MSComctlLib.StatusBar sbRS 
      Align           =   2  'Align Bottom
      Height          =   285
      Left            =   0
      TabIndex        =   10
      Top             =   6975
      Width           =   10635
      _ExtentX        =   18759
      _ExtentY        =   503
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   5
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
         EndProperty
         BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Alignment       =   1
            AutoSize        =   1
            Bevel           =   0
            Object.Width           =   5532
            MinWidth        =   2
         EndProperty
         BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel5 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin ITGControls.ITGTab SSTab2 
      Height          =   2820
      Left            =   0
      TabIndex        =   20
      Top             =   3465
      Width           =   10455
      _ExtentX        =   18441
      _ExtentY        =   4974
      TabCount        =   2
      TabCaption(0)   =   "Account/Asset"
      TabContCtrlCnt(0)=   2
      Tab(0)ContCtrlCap(1)=   "cboTRType"
      Tab(0)ContCtrlCap(2)=   "dtgAR"
      TabCaption(1)   =   "Loan/TD"
      TabContCtrlCnt(1)=   2
      Tab(1)ContCtrlCap(1)=   "cboTDType"
      Tab(1)ContCtrlCap(2)=   "dtgTD"
      ActiveTab       =   1
      TabTheme        =   2
      ActiveTabBackStartColor=   16250865
      ActiveTabBackEndColor=   16243138
      InActiveTabBackStartColor=   16243138
      InActiveTabBackEndColor=   16243138
      InActiveTabForeColor=   0
      BeginProperty ActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty InActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      OuterBorderColor=   4210752
      TopLeftInnerBorderColor=   4210752
      BottomRightInnerBorderColor=   4210752
      DisabledTabBackColor=   16243138
      DisabledTabForeColor=   -2147483630
      Begin VB.ComboBox cboTDType 
         Height          =   315
         ItemData        =   "frmGLCredit.frx":014A
         Left            =   75
         List            =   "frmGLCredit.frx":0166
         Style           =   2  'Dropdown List
         TabIndex        =   24
         Top             =   2235
         Visible         =   0   'False
         Width           =   1035
      End
      Begin VB.ComboBox cboTRType 
         Height          =   315
         ItemData        =   "frmGLCredit.frx":0192
         Left            =   -74895
         List            =   "frmGLCredit.frx":01AE
         Style           =   2  'Dropdown List
         TabIndex        =   23
         Top             =   2220
         Visible         =   0   'False
         Width           =   1035
      End
      Begin MSDataGridLib.DataGrid dtgAR 
         Height          =   2505
         Left            =   -75000
         TabIndex        =   22
         Top             =   315
         Width           =   10455
         _ExtentX        =   18441
         _ExtentY        =   4419
         _Version        =   393216
         AllowUpdate     =   -1  'True
         AllowArrows     =   -1  'True
         Appearance      =   0
         BackColor       =   16777215
         HeadLines       =   1
         RowHeight       =   15
         TabAcrossSplits =   -1  'True
         TabAction       =   2
         FormatLocked    =   -1  'True
         AllowDelete     =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   5
         BeginProperty Column00 
            DataField       =   "cType"
            Caption         =   "Type"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   "cAcctNo"
            Caption         =   "Account/Asset"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column02 
            DataField       =   "cTitle"
            Caption         =   "Title / Description"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column03 
            DataField       =   "cDesc"
            Caption         =   "Description"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column04 
            DataField       =   "nAmount"
            Caption         =   "Amount"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
               Button          =   -1  'True
               ColumnWidth     =   870.236
            EndProperty
            BeginProperty Column01 
               Button          =   -1  'True
               ColumnWidth     =   1305.071
            EndProperty
            BeginProperty Column02 
               Locked          =   -1  'True
               ColumnWidth     =   2954.835
            EndProperty
            BeginProperty Column03 
               ColumnWidth     =   3209.953
            EndProperty
            BeginProperty Column04 
               Alignment       =   1
               ColumnWidth     =   1560.189
            EndProperty
         EndProperty
      End
      Begin MSDataGridLib.DataGrid dtgTD 
         Height          =   2505
         Left            =   0
         TabIndex        =   21
         Top             =   315
         Width           =   10455
         _ExtentX        =   18441
         _ExtentY        =   4419
         _Version        =   393216
         AllowUpdate     =   -1  'True
         AllowArrows     =   -1  'True
         Appearance      =   0
         BackColor       =   16777215
         HeadLines       =   1
         RowHeight       =   15
         TabAcrossSplits =   -1  'True
         TabAction       =   2
         FormatLocked    =   -1  'True
         AllowDelete     =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   7
         BeginProperty Column00 
            DataField       =   "cType"
            Caption         =   "Type"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   "cLoanTDNo"
            Caption         =   "LR / TD No."
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column02 
            DataField       =   "dDateFrom"
            Caption         =   "Date From"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "M/d/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   3
            EndProperty
         EndProperty
         BeginProperty Column03 
            DataField       =   "dDateTo"
            Caption         =   "Date To"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "M/d/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   3
            EndProperty
         EndProperty
         BeginProperty Column04 
            DataField       =   "nRate"
            Caption         =   "Rate"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column05 
            DataField       =   "nPrincipal"
            Caption         =   "Principal"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column06 
            DataField       =   "nAmount"
            Caption         =   "Amount"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
               Button          =   -1  'True
               ColumnWidth     =   945.071
            EndProperty
            BeginProperty Column01 
               Button          =   -1  'True
            EndProperty
            BeginProperty Column02 
               ColumnWidth     =   1379.906
            EndProperty
            BeginProperty Column03 
               ColumnWidth     =   1425.26
            EndProperty
            BeginProperty Column04 
               Alignment       =   1
               ColumnWidth     =   1275.024
            EndProperty
            BeginProperty Column05 
               Alignment       =   1
               ColumnWidth     =   1769.953
            EndProperty
            BeginProperty Column06 
               Alignment       =   1
               ColumnWidth     =   1590.236
            EndProperty
         EndProperty
      End
   End
End
Attribute VB_Name = "frmGLCredit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'IT Group Inc. 2005.09.23

Option Explicit

'Object variables





'Recordset variables
Private WithEvents rsHeader As ADODB.Recordset
Attribute rsHeader.VB_VarHelpID = -1
Private rsDetail As ADODB.Recordset
Private rsLoanTD As ADODB.Recordset

'ADO Connection variables

Private connHeader As ADODB.Connection
Private connDetail As ADODB.Connection
Private connLoanTD As ADODB.Connection

'Form mode enumeration
Enum xCreditMode
    Normal
    AddNewEdit
    Find
End Enum
Public Mode As xCreditMode

'Other declarations
Public dtgName As String
Public sBit As String
Private vBM As Variant 'Recordset bookmark variable

Private lSystemGenerated As Boolean
Public strNo As String

'Private sInv As String
Public nAmount As Double

'Security Acess Level variables
Public lACNew As Boolean
Public lACEdit As Boolean
Public lACDelete As Boolean
Public lACPost As Boolean
Public lACCancel As Boolean
Public lACPrint As Boolean

Private Sub cmdPickClient_Click()
    If lPickListActive Then Exit Sub
    sFilterString = Trim(txtCode)
    frmITGPicker.zType = QBank
    frmITGPicker.Show vbModal
    txtCode = frmITGPicker.zCode
    txtName = frmITGPicker.zName
    If Trim(txtName) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub dtgAR_AfterColUpdate(ByVal ColIndex As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 1
            If GetValueFrTable("cAcctNo", "ACCOUNT", "cAcctNo = '" & Trim(dtgAR.Columns(1).Text) & "' and cType = 'Details' ") <> "" Then
                dtgAR.Columns(2).Value = GetValueFrTable("cTitle", "ACCOUNT", "cAcctNo = '" & Trim(dtgAR.Columns(1).Text) & "'")
                dtgAR.Columns(3).Value = rsDetail!cDesc
            ElseIf GetValueFrTable("cAcctNo", "ACCOUNT", "cAcctNo = '" & Trim(dtgAR.Columns(1).Text) & "' and cType = 'General' ") <> "" Then
                MsgBox "General Account.", vbInformation
                dtgAR.Columns(ColIndex).Text = ""
                dtgAR.Col = ColIndex
                dtgAR.SetFocus
            End If
        Case 4
            TotalAmount
    End Select
End Sub

Private Sub dtgAR_ButtonClick(ByVal ColIndex As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 0
            Call MoveCombo(cboTRType, dtgAR, dtgAR.Columns(0))
            ComboLoadValue cboTRType, Trim(dtgAR.Columns(0).Text)
        Case 1
            If lPickListActive Then Exit Sub
            sFilterString = Trim(dtgAR.Columns(1).Text)
            frmITGPicker.zType = QAccounts
            frmITGPicker.Show vbModal
            If Trim(frmITGPicker.zCode) = "" Then Exit Sub
            dtgAR.Columns(1).Value = frmITGPicker.zCode & ""
            dtgAR.Columns(2).Value = frmITGPicker.zName & ""
            dtgAR.Col = 3
            dtgAR.Columns(3).Value = rsDetail!cDesc
    End Select
End Sub

'Set the datagrid as active control
Private Sub dtgAR_Click()
    If Mode = AddNewEdit Then dtgName = dtgAR.Name
End Sub

Private Sub dtgAR_Error(ByVal DataError As Integer, Response As Integer)
    If Mode <> AddNewEdit Then
        Response = 0
        Exit Sub
    End If
    If DataError = 7007 Then
        MsgBox "Type mismatch", vbExclamation, "ComUnion"
    ElseIf DataError = 13 Then
        MsgBox "Type mismatch", vbExclamation, "ComUnion"
    End If
    Response = 0
End Sub

Private Sub dtgAR_GotFocus()
    dtgName = dtgAR.Name
End Sub

Private Sub dtgAR_KeyDown(KeyCode As Integer, Shift As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If (Shift = vbCtrlMask And KeyCode = 45) Then
        TBNewLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 46) Then
        TBDeleteLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 83) Then
        TBSave
    End If
End Sub

Private Sub dtgAR_KeyPress(KeyAscii As Integer)

    If Mode <> AddNewEdit Then Exit Sub
    If rsDetail.RecordCount = 0 Then Exit Sub

    If KeyAscii = 39 Then KeyAscii = 0 'Apostrophe {'}

    If KeyAscii = 13 Then
        Select Case dtgAR.Col
            Case 0
                If Not cboTRType.Visible Then dtgAR_ButtonClick (0)
            Case 1
                If GetValueFrTable("cAcctNo", "ACCOUNT", "cAcctNo = '" & Trim(dtgAR.Columns(1).Text) & "'") = "" Then
                    dtgAR_ButtonClick (1)
                    Exit Sub
                End If
                SendKeys "{Tab}"
                SendKeys "{Tab}"
            Case 4
                TBNewLine
                dtgAR.LeftCol = 0
            Case Else
                SendKeys "{Tab}"
        End Select
    Else
        KeyAscii = Asc(UCase(Chr(KeyAscii)))
    End If

End Sub

'Right click menu popup
Private Sub dtgAR_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Mode <> AddNewEdit Then Exit Sub
    If Button = 2 Then
        dtgName = dtgAR.Name
        PopupMenu ITGLedgerMain.mnuDetail
    End If
End Sub

Private Sub dtgTD_AfterColUpdate(ByVal ColIndex As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 1
            If dtgTD.Columns(0).Value = "LRL" Then
                If IDExisting(rsLoanTD, "cLoanTDNo", "LOANTD", Trim(dtgTD.Columns(1).Value)) Then
                    MsgBox "ID already exists!"
                Else
                    SendKeys "{Tab}"
                End If
            ElseIf dtgTD.Columns(0).Value = "TTD" Then
                If GetValueFrTable("cLoanTDNo", "LOANTD", "cLoanTDNo = '" & Trim(dtgTD.Columns(1).Text) & "'") <> "" Then
                    dtgTD.Columns(1).Value = GetValueFrTable("cLoanTDNo", "LOANTD", "cLoanTDNo = '" & Trim(dtgTD.Columns(1).Text) & "'")
                End If
            Else
                SendKeys "{Tab}"
            End If
        Case 5
            If dtgTD.Columns(0).Value = "LRL" Then
                dtgTD.Columns(6).Value = rsLoanTD!nPrincipal
                SendKeys "{Tab}"
            ElseIf dtgTD.Columns(0).Value = "INT" Then
                dtgTD.Columns(6).Value = Round(rsLoanTD!nPrincipal * (rsLoanTD!nRate / 100) * (rsLoanTD!dDateTo - rsLoanTD!dDateFrom) / 360, 2)
                SendKeys "{Tab}"
            End If
        Case 6
            TotalAmount
            
    End Select
End Sub

Private Sub dtgTD_ButtonClick(ByVal ColIndex As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 0
            Call MoveCombo(cboTDType, dtgTD, dtgTD.Columns(0))
            ComboLoadValue cboTDType, Trim(dtgTD.Columns(0).Text)
        Case 1
            If dtgTD.Columns(0).Value = "LRL" Then
                If IDExisting(rsLoanTD, "cLoanTDNo", "LOANTD", Trim(dtgTD.Columns(1).Text)) Then
                    MsgBox "ID already exists!"
                Else
                    SendKeys "{Tab}"
                End If
            ElseIf dtgTD.Columns(0).Value = "TTD" Then
                If lPickListActive Then Exit Sub
                sFilterString = Trim(dtgTD.Columns(1).Text)
                frmITGPickList.mType = TimeDeposit
                frmITGPickList.Show vbModal
                If Trim(frmITGPickList.mCode) = "" Then Exit Sub
                dtgTD.Columns(1).Value = frmITGPickList.mCode & ""
                dtgTD.Columns(2).Value = frmITGPickList.mDate
                dtgTD.Columns(3).Value = frmITGPickList.mUnit
                dtgTD.Columns(4).Value = frmITGPickList.mQty
                dtgTD.Columns(5).Value = frmITGPickList.mName
                dtgTD.Col = 6
                dtgTD.Columns(6).Value = GetValueFrTable("nBalance", "V_LOAN_TD", "cLoanTDNo = '" & dtgTD.Columns(1).Text & "'")
            ElseIf dtgTD.Columns(0).Value = "INT" Then
                If lPickListActive Then Exit Sub
                sFilterString = Trim(dtgTD.Columns(1).Text)
                frmITGPickList.mType = TimeDeposit
                frmITGPickList.Show vbModal
                If Trim(frmITGPickList.mCode) = "" Then Exit Sub
                dtgTD.Columns(1).Value = frmITGPickList.mCode & ""
                dtgTD.Columns(2).Value = frmITGPickList.mDate
                dtgTD.Columns(3).Value = frmITGPickList.mUnit
                dtgTD.Columns(4).Value = frmITGPickList.mQty
                dtgTD.Columns(5).Value = frmITGPickList.mName
                'dtgTD.Col = 6
                dtgTD.Columns(6).Value = Round(rsLoanTD!nPrincipal * (rsLoanTD!nRate / 100) * (rsLoanTD!dDateTo - rsLoanTD!dDateFrom) / 360, 2)
            ElseIf dtgTD.Columns(0).Value = "EXT" Then
            
            End If
    End Select
End Sub

'Set the datagrid as active control
Private Sub dtgTD_Click()
    If Mode = AddNewEdit Then dtgName = dtgTD.Name
End Sub

Private Sub dtgTD_Error(ByVal DataError As Integer, Response As Integer)
    If Mode <> AddNewEdit Then
        Response = 0
        Exit Sub
    End If
    If DataError = 7007 Then
        MsgBox "Type mismatch", vbExclamation, "ComUnion"
    ElseIf DataError = 13 Then
        MsgBox "Type mismatch", vbExclamation, "ComUnion"
    End If
    Response = 0
End Sub

Private Sub dtgTD_GotFocus()
    dtgName = dtgTD.Name
End Sub

Private Sub dtgTD_KeyDown(KeyCode As Integer, Shift As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If (Shift = vbCtrlMask And KeyCode = 45) Then
        TBNewLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 46) Then
        TBDeleteLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 83) Then
        TBSave
    End If
End Sub

Private Sub dtgTD_KeyPress(KeyAscii As Integer)
Dim tmpValue1 As String
Dim tmpValue2 As Date
Dim tmpValue3 As Date
Dim tmpValue4 As Double
Dim tmpValue5 As Double
Dim tmpValue6 As Double

    If Mode <> AddNewEdit Then Exit Sub
    If rsLoanTD.RecordCount = 0 Then Exit Sub

    If KeyAscii = 39 Then KeyAscii = 0 'Apostrophe {'}

    If KeyAscii = 13 Then
        Select Case dtgTD.Col
            Case 0
                If Not cboTDType.Visible Then dtgTD_ButtonClick (0)
            Case 1
                If dtgTD.Columns(0).Value = "LRL" Then
                    
                ElseIf dtgTD.Columns(0).Value = "TTD" Then
                    If GetValueFrTable("cLoanTDNo", "LOANTD", "cLoanTDNo = '" & Trim(dtgTD.Columns(1).Text) & "'") = "" Then
                        dtgTD_ButtonClick (1)
                        Exit Sub
                    End If
                ElseIf dtgTD.Columns(0).Value = "INT" Then
                    If GetValueFrTable("cLoanTDNo", "LOANTD", "cLoanTDNo = '" & Trim(dtgTD.Columns(1).Text) & "'") = "" Then
                        dtgTD_ButtonClick (1)
                        SendKeys "{Tab}"
                        Exit Sub
                    End If
                ElseIf dtgTD.Columns(0).Value = "EXT" Then
                End If
            Case 5
                If dtgTD.Columns(0).Value = "LRL" Then
                    dtgTD.Columns(6).Value = rsLoanTD!nPrincipal
                    SendKeys "{Tab}"
                ElseIf dtgTD.Columns(0).Value = "INT" Then
                    dtgTD.Columns(6).Value = Round(rsLoanTD!nPrincipal * (rsLoanTD!nRate / 100) * (rsLoanTD!dDateTo - rsLoanTD!dDateFrom) / 360, 2)
                    SendKeys "{Tab}"
                End If
            Case 6
                TotalAmount
                If dtgTD.Columns(0).Value = "LRL" Then
                    tmpValue1 = dtgTD.Columns(1).Value
                    tmpValue2 = dtgTD.Columns(2).Value
                    tmpValue3 = dtgTD.Columns(3).Value
                    tmpValue4 = dtgTD.Columns(4).Value
                    tmpValue5 = dtgTD.Columns(5).Value
                    TBNewLine
                    'dtgTD.LeftCol = 0
                    dtgTD.Columns(0).Value = "EXP"
                    dtgTD.Columns(1).Value = tmpValue1
                    dtgTD.Columns(2).Value = tmpValue2
                    dtgTD.Columns(3).Value = tmpValue3
                    dtgTD.Columns(4).Value = tmpValue4
                    dtgTD.Columns(5).Value = tmpValue5
                    dtgTD.Columns(6).Value = tmpValue5 * (tmpValue4 / 100) * (tmpValue3 - tmpValue2) / 360
                    dtgTD.LeftCol = 5
                Else
                    TBNewLine
                    dtgTD.LeftCol = 0
                End If
            Case Else
                SendKeys "{Tab}"
        End Select
    Else
        KeyAscii = Asc(UCase(Chr(KeyAscii)))
    End If

End Sub

'Right click menu popup
Private Sub dtgTD_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Mode <> AddNewEdit Then Exit Sub
    If Button = 2 Then
        dtgName = dtgTD.Name
        PopupMenu ITGLedgerMain.mnuDetail
    End If
End Sub


Private Sub dtgList_HeadClick(ByVal ColIndex As Integer)
    SortGrid dtgList, ColIndex, rsHeader
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Dim iKey As Integer
    iKey = ToolbarIndex(KeyCode, Shift)
    If iKey <> 0 Then
        If ITGLedgerMain.tbrMain.Buttons(iKey).Enabled = True Then
            ToolbarFunction iKey
        End If
    End If
End Sub

'Set Your Object
Private Sub Form_Load()

    Set FrmName = Me
    FormSetup

    AcessBit Me, GetValueFrTable("AccessLevel", "SEC_ACCESSLEVEL", "RoleID = '" & SecUserRole & "' AND [Module] = 'AR03'")

    Set rsHeader = New ADODB.Recordset
    Set rsDetail = New ADODB.Recordset
    Set rsLoanTD = New ADODB.Recordset
    

    Set FrmName = Me
    FormLocking True
    FormSearch True
    SearchObj True
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
    BitVisible ITGLedgerMain.tbrMain, True, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True

    Mode = Find
    txtTranNo.Locked = False
    
    cboTRType.Clear
    cboTRType.AddItem ("CRM")
    cboTRType.AddItem ("ADP")
    cboTDType.Clear
    cboTDType.AddItem ("TTD")
    cboTDType.AddItem ("AVM")
    cboTDType.AddItem ("LRL")
    cboTDType.AddItem ("EXP")
    cboTDType.AddItem ("INT")

End Sub

'Activate your Toolbar Mode
Private Sub Form_Activate()
    TBBitReload
End Sub

'Release your Object
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
    If Mode = AddNewEdit Then
        MsgBox "Unable to close. You are in Add/New/Edit mode." & vbCr & _
            " Must Save or Undo", vbCritical, Me.Caption
        Cancel = True
        Exit Sub
    End If
    
    CloseMenuTab ITGLedgerMain

    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , , , , , , , True
    BitVisible ITGLedgerMain.tbrMain
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = False

    
    
    
    
    Set rsHeader = Nothing
    Set rsDetail = Nothing
    Set rsLoanTD = Nothing
    Set connHeader = Nothing
    Set connDetail = Nothing
    Set connLoanTD = Nothing

    Set frmGLCredit = Nothing

    lCloseWindow = True
    
'    'oForm(Me.Tag).Mode = 1
'    'oForm(Me.Tag).Tag = Me.Tag
End Sub

'Add new record to the recordset
Public Sub TBNew()

    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    txtTranNo.BackColor = &HE0FFFF
    Mode = AddNewEdit

    If rsHeader.State <> adStateOpen Then
        OpenNewConnection connHeader
        OpenNewConnection connDetail
        OpenNewConnection connLoanTD
        OpenRecordsetWithCN rsDetail, "*", "CREDIT_CMDM", connDetail, "WHERE 1 = 0"
        OpenRecordsetWithCN rsLoanTD, "*", "CREDIT_LOANTD", connLoanTD, "WHERE 1 = 0"
        OpenRecordsetWithCN rsHeader, "*", "CREDIT", connHeader, "WHERE 1 = 0"
        SetDataSource
        SetDataField
    Else
        vBM = rsHeader.Bookmark
    End If

    rsHeader.AddNew
    rsHeader!cCompanyID = COID
    rsHeader!dDate = Date
    rsHeader!cTranType = "Credit"

    Set FrmName = Me
    FormLocking False
    ClrRequired &HC0&
    txtGross.Locked = True
    SSTab1.ActiveTab = 0
    SSTab2.ActiveTab = 0
    txtTranNo.SetFocus
    
    
'System generated number
    lSystemGenerated = GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'AUTO_NUMBER_CM' ")
    If lSystemGenerated Then rsHeader!cTranNo = GetAutoCtrlNo(rsHeader, "AUTO_NUMBER_CM", "CREDIT", "cTranNo")

End Sub

'Undo all changes to the recordset
Public Sub TBUndoAll()
On Error GoTo ErrorHandler

    Mode = Normal

    If rsHeader.Status = adRecNew Then TBUndoCurrent

    rsHeader.CancelBatch adAffectAll
    rsDetail.CancelBatch adAffectAll
    rsLoanTD.CancelBatch adAffectAll

    UnbindControls

    If rsHeader.RecordCount <> 0 Then rsHeader.Bookmark = vBM

    Set FrmName = Me
    FormLocking True
    If rsHeader.RecordCount <> 0 Then
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , lACPost, lACCancel, , , True, True, , True, True
    Else
        RSZero
        Mode = Find
    End If

    sbRS.Panels(2) = ""

    SetDataSource
    SetDataField

ErrorHandler:
    cboTRType.Visible = False
    cboTDType.Visible = False
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoAll
    End If

End Sub

'Undo changes on the current record
Public Sub TBUndoCurrent()
On Error GoTo ErrorHandler

    GetChild
    If rsHeader.Status = adRecNew Then
        rsDetail.CancelBatch adAffectAll
        rsLoanTD.CancelBatch adAffectAll
        rsHeader.CancelUpdate
    Else
        rsHeader.CancelBatch adAffectCurrent
        rsLoanTD.CancelBatch adAffectCurrent
        rsDetail.CancelBatch adAffectAll
    End If

    If rsHeader.RecordCount = 0 Then RSZero

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoCurrent
    End If

End Sub

'Save all changes
Public Sub TBSave()
Dim OKUpdate As Boolean
On Error GoTo ErrHandler

    lSaving = True

    'Audit Trail
    lBoolean = False
    If rsHeader.Status = adRecNew Then lBoolean = True

    If Not MandatoryOK Then Exit Sub
    
    'System generated number
    If rsHeader.Status = adRecNew Then
    
        If lSystemGenerated Then
            If ChkCtrlNo(rsHeader, "AUTO_NUMBER_CM", "CREDIT", "cTranNo", rsHeader!cTranNo) <> rsHeader!cTranNo Then
                GetChild
                
                rsHeader!cTranNo = strNo
                
                If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
                Do Until rsDetail.EOF
                    rsDetail!cTranNo = strNo
                    rsDetail.MoveNext
                Loop
                
                If rsLoanTD.RecordCount <> 0 Then rsLoanTD.MoveFirst
                Do Until rsLoanTD.EOF
                    rsLoanTD!cTranNo = strNo
                    rsLoanTD.MoveNext
                Loop
                
                GetChild
            End If
        End If
    End If

    OKUpdate = False
    cn.BeginTrans
    connHeader.BeginTrans
    connDetail.BeginTrans
    connLoanTD.BeginTrans

    rsHeader.UpdateBatch adAffectAll
    rsDetail.UpdateBatch adAffectAll
    rsLoanTD.UpdateBatch adAffectAll
    
    cn.CommitTrans
    connHeader.CommitTrans
    connDetail.CommitTrans
    connLoanTD.CommitTrans
    OKUpdate = True

    Set FrmName = Me
    FormLocking True
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , lACPost, lACCancel, , , True, True, , True, True
    Mode = Normal

    If rsLoanTD.RecordCount <> 0 Then UpdateLoanTD
    
    'Update GL Activity
    UpdateGLA "Update", "CRM", Trim(txtTranNo)
    
    'Audit trail
    UpdateLogFile "Fund Management - Credit", Trim(txtTranNo), IIf(lBoolean, "Inserted", "Updated")

    'update system generated number
    If lBoolean Then
        If lSystemGenerated And strNo = rsHeader!cTranNo Then UpdateControlNo strNo, rsHeader!cTranNo, "AUTO_NUMBER_CM"
    End If
    
    MsgBox "Record/s successfully saved.", vbInformation, "ComUnion"
    sbRS.Panels(2) = ""
    
    
    
ErrHandler:
    cboTRType.Visible = False
    cboTDType.Visible = False
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217864 Then
        OKUpdate = True
        cn.RollbackTrans
        connHeader.RollbackTrans
        connDetail.RollbackTrans
        connLoanTD.RollbackTrans
        MsgBox "Record cannot be updated. Some values may have been changed by other user/s since last read." & vbCr & _
                "Records will be automatically refreshed. All changes made to the record will be gone upon refresh.", vbInformation, "ComUnion"
        vBookMark = rsHeader.Bookmark
        UnbindControls
        rsHeader.Requery
        rsDetail.Requery
        rsLoanTD.Requery
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , lACPost, lACCancel, , , True, True, , True
        Mode = Normal
        If rsHeader.RecordCount <> 0 Then
            Set FrmName = Me
            FormLocking True
            SetDataField
            SetDataSource
            rsHeader.Bookmark = vBookMark
        Else
            RSZero
        End If
    End If
    If Not OKUpdate Then
        MsgBox "Transaction update failed.", vbInformation, "ComUnion"
        cn.RollbackTrans
        connHeader.RollbackTrans
        connDetail.RollbackTrans
        connLoanTD.RollbackTrans
        ErrorLog err.Number, err.Description, Me.Name 'Error log
    End If
    lSaving = False
End Sub

'Sets the form & recorset to add/edit mode
Public Sub TBEdit()
    Mode = AddNewEdit
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    Set FrmName = Me
    FormLocking False
    ClrRequired &HC0&
    'cboType.Locked = True
    txtGross.Locked = True
    txtTranNo.Locked = True
    SSTab1.ActiveTab = 0
    dtbDate.SetFocus
    vBM = rsHeader.Bookmark
End Sub

'Delete record
Public Sub TBDelete()
On Error GoTo ErrorHandler

    sID = Trim(txtTranNo)

    If rsHeader.RecordCount = 0 Then Exit Sub

    If MsgBox("Are you sure you want to delete this record?", vbQuestion + vbYesNo, "ComUnion") = vbNo Then Exit Sub

    GetChild
    If rsDetail.RecordCount <> 0 Then
        rsDetail.MoveFirst
        Do Until rsDetail.RecordCount = 0
            rsDetail.Delete adAffectCurrent
            If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
        Loop
    End If

    If rsLoanTD.RecordCount <> 0 Then
        rsLoanTD.MoveFirst
        Do Until rsLoanTD.RecordCount = 0
            rsLoanTD.Delete adAffectCurrent
            If rsLoanTD.RecordCount <> 0 Then rsLoanTD.MoveFirst
        Loop
    End If
    
    'Update GL Activity
    UpdateGLA "Delete", "CRM", Trim(txtTranNo)
    
    'Audit trail
    UpdateLogFile "Fund Management - Credit", Trim(txtTranNo), "Deleted"

    rsHeader.Delete adAffectCurrent

    rsDetail.UpdateBatch adAffectAll
    rsLoanTD.UpdateBatch adAffectAll
    rsHeader.UpdateBatch adAffectAll
    
    cn.Execute "DELETE LOANTD WHERE cTranNo = '" & Trim(txtTranNo) & "' AND cCompanyID = '" & COID & "' AND cType = 'LOAN'"
    
    TBPrevRec

    Mode = Normal

    If rsHeader.RecordCount = 0 Then
        RSZero
    End If

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217864 Then
        cn.Execute "DELETE Credit_CMDM WHERE cTranNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        cn.Execute "DELETE Credit_LOANTD WHERE cTranNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        cn.Execute "DELETE Credit WHERE cTranNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        Resume Next
    End If

End Sub

'Search using the frmITGSearch
Public Sub TBFind()
    Mode = Normal
    txtTranNo.Locked = True
    frmITGSearch.Show 'vbModal
End Sub

'Search using the recordset primary key
Public Sub TBFindPrimary()
Dim sTemp As String
If Mode = Find Then
    FormWaitShow App.Path & "\Transmit.avi", "Loading data . . ."

    OpenNewConnection connHeader
    OpenNewConnection connDetail
    OpenNewConnection connLoanTD

    Set rsHeader = Nothing
    Set rsDetail = Nothing
    Set rsLoanTD = Nothing
    Set rsHeader = New ADODB.Recordset
    Set rsDetail = New ADODB.Recordset
    Set rsLoanTD = New ADODB.Recordset

    sTemp = Trim$(GetSearchString)
    If sTemp = "ERROR" Then
        MsgBox "Only Allows A - Z, 0 - 9, '.', ',' and %(wildcard)", vbExclamation, ""
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
        txtTranNo.Locked = False
        txtTranNo.SetFocus
        Exit Sub
    End If
    
    OpenRecordsetWithCN rsHeader, "*", "CREDIT", connHeader, IIf(sTemp = "", "", " WHERE " & sTemp)
    'OpenRecordsetWithCN rsDetail, "*", "CREDIT_CMDM", connDetail
    'OpenRecordsetWithCN rsLoanTD, "*", "CREDIT_LOANTD", connLoanTD
         
    OpenRecordsetWithCN rsDetail, "*", "CREDIT_CMDM", connDetail, IIf(sTemp = "", "", " WHERE cTranNo IN (SELECT cTranNo FROM CREDIT WHERE " & sTemp & ")")
    OpenRecordsetWithCN rsLoanTD, "*", "CREDIT_LOANTD", connLoanTD, IIf(sTemp = "", "", " WHERE cTranNo IN (SELECT cTranNo FROM CREDIT WHERE " & sTemp & ")")
       
    Set FrmName = Me
    FormLocking True
            
    If rsHeader.RecordCount = 0 Then
        FormWaitHide
        MsgBox "No matching record/s found.", vbInformation, "ComUnion Search"
        RSZero
        FormSearch True
        SearchObj True
        Mode = Find
        Exit Sub
    End If
    SetDataSource
    SetDataField
    txtTranNo.BackColor = &HE0FFFF
    Mode = Normal
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , lACPost, lACCancel, , , True, True, , True, True

    FormWaitHide
Else
    RSZero
    FormSearch True
    SearchObj True
    Mode = Find
End If

End Sub

Public Sub TBAccountAffected()
    RepName = "CRM"
    frmAccountAffected.mModuleType = KCREDIT
    frmAccountAffected.mRefPK = txtTranNo.Text
    frmAccountAffected.Show vbModal
End Sub

'Reload menu buttons (do not delete this sub)
Public Sub TBBitReload()
    BitVisible ITGLedgerMain.tbrMain, True, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True
    BitReload ITGLedgerMain, Me, ITGLedgerMain.tbrMain, sBit
    Set FrmName = Me
    dtgName = dtgAR.Name
End Sub

'Close active window
Public Sub TBCloseWindow()
    Unload Me
End Sub

'Move first
Public Sub TBFirstRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveFirst rsHeader

End Sub

'Move previuos
Public Sub TBPrevRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MovePrevious rsHeader

End Sub

'Move next
Public Sub TBNextRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveNext rsHeader

End Sub

'Move last
Public Sub TBLastRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveLast rsHeader

End Sub

'Add new line to the detail recordset
Public Sub TBNewLine()

    If rsHeader!cTranNo = "" Then Exit Sub

    If dtgName = "dtgAR" Then
        rsDetail.AddNew
        rsDetail!cCompanyID = COID
        rsDetail!cTranNo = Trim(rsHeader!cTranNo)
        dtgAR.Col = 3
        GetChild
        If rsDetail.RecordCount <> 0 Then rsDetail.MoveLast
        dtgAR.Col = 0
        dtgAR.SetFocus
    ElseIf dtgName = "dtgTD" Then
        rsLoanTD.AddNew
        rsLoanTD!cCompanyID = COID
        rsLoanTD!cTranNo = Trim(txtTranNo)
        dtgTD.Col = 0
        GetChild
        If rsLoanTD.RecordCount <> 0 Then rsLoanTD.MoveLast
        dtgTD.SetFocus
    End If

    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True

End Sub

'Delete line in the detail recordset
Public Sub TBDeleteLine()
On Error GoTo ErrorHandler

    If dtgName = dtgAR.Name Then
        If rsDetail.RecordCount = 0 Then Exit Sub
        vBookMark = dtgAR.Bookmark
        GetChild
        dtgAR.Bookmark = vBookMark
        rsDetail.Delete adAffectCurrent
    ElseIf dtgName = "dtgTD" Then
        If rsLoanTD.RecordCount = 0 Then Exit Sub
        vBookMark = dtgTD.Bookmark
        GetChild
        dtgTD.Bookmark = vBookMark
        rsLoanTD.Delete adAffectCurrent
    End If
    GetChild

    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If
End Sub

'Undo All
Public Sub TBUndoLineAll()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Undo current line
Public Sub TBUndoLineCurrent()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Post current record
Public Sub TBPostRecord()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Cancel current record
Public Sub TBCancelRecord()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Print
Public Sub TBPrintRecord()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Sets the data source of the controls
Sub SetDataSource()
    Set FrmName = Me
    BindControls rsHeader
    Set dtgList.DataSource = rsHeader
    Set dtgAR.DataSource = rsDetail
    Set dtgTD.DataSource = rsLoanTD

End Sub

'Sets the data field for every bounded controls
Sub SetDataField()
    With rsHeader
        txtTranNo.DataField = !cTranNo
        dtbDate.DataField = !dDate
        txtType.DataField = !cTranType
        txtCode.DataField = !cBankID
        txtRemarks.DataField = !cRemarks
        txtGross.DataField = !nGross
    End With
End Sub

Private Sub rsHeader_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
On Error GoTo ErrorHandler

    If Not (rsHeader.EOF) Or Not (rsHeader.BOF) Then
        'Status bar setup
        sbRS.Panels(1) = "Record: " & IIf((rsHeader.AbsolutePosition = -2), "0", rsHeader.AbsolutePosition) & "/" & rsHeader.RecordCount

        If rsHeader.Status <> adRecNew Then
            txtTranNo.Locked = True
        Else
            txtTranNo.Locked = False
        End If

        If Mode = AddNewEdit Then
            Select Case rsHeader.Status
                Case adRecNew
                    sbRS.Panels(2) = "New"
                Case adRecModified
                    sbRS.Panels(2) = "Modified"
                Case Else
                    sbRS.Panels(2) = ""
            End Select
        Else
            sbRS.Panels(2) = ""
        End If

        GetChild

    Else
        sbRS.Panels(1) = "Record: 0/0"
        sbRS.Panels(2) = ""
        txtTranNo.Locked = False
    End If

    If Mode = AddNewEdit Then
        dtgAR.Refresh
        dtgTD.Refresh
    End If

ErrorHandler:
    'Err.Number -2147217885
    'Description - Row handle referred to a deleted row or a row marked for deletion.
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

Private Sub Timer1_Timer()
    If Mode = AddNewEdit Then
        SSTab1.TabEnabled(1) = False
    Else
        SSTab1.TabEnabled(1) = True
    End If
End Sub

Private Sub txtCode_Change()
    txtName = ""
    txtName = GetValueFrTable("cBankName", "BANK", "cBankID = '" & Trim(txtCode) & "'")
End Sub

Private Sub txtCode_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtName) = "" And Trim(txtCode) <> "" Then cmdPickClient_Click
End Sub

Private Sub txtRemarks_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If rsDetail.RecordCount = 0 Then TBNewLine
End Sub

Private Sub txtTranNo_LostFocus()
    'Does Code Already Exist
    If Mode = AddNewEdit Then
        If Trim(txtTranNo) = "" Then
            MsgBox "Empty primary input.", vbInformation, "ComUnion"
            txtTranNo.SetFocus
        Else
            If rsHeader.Status <> adRecNew Then Exit Sub
            txtTranNo = Trim(txtTranNo)
            If IDExisting(rsHeader, "cTranNo", "Credit", Trim(rsHeader!cTranNo)) Then
                MsgBox "Transaction No. already exist.", vbInformation, "ComUnion"
                txtTranNo.SetFocus
            End If
        End If
    End If
End Sub

'Check if all mandatory fields are complete
Function MandatoryOK() As Boolean

    MandatoryOK = True

    If Trim(txtTranNo) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Transaction Number' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        txtTranNo.SetFocus
        Exit Function
    End If

    TotalAmount

    If rsHeader.Status = adRecNew And lSystemGenerated = False Then
        If IDExisting(rsHeader, "cTranNo", "Credit", Trim(rsHeader!cTranNo)) Then
            MandatoryOK = False
            MsgBox "Transaction No. already exist.", vbInformation, "ComUnion"
            txtTranNo.SetFocus
            Exit Function
        End If
    End If

    'Required fields
    If Trim(dtbDate.Text) = "__/__/____" Then
        MandatoryOK = False
        MsgBox "Field 'Transaction Date' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        dtbDate.SetFocus
        Exit Function
    ElseIf Trim(txtType) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Type' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        Exit Function
    ElseIf Trim(txtCode) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Bank ID' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        txtCode.SetFocus
        Exit Function
    End If

    GetChild

    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        If rsDetail.Status = (adRecNew) Or rsDetail.Status = (adRecModified) Then
            If IsNull(rsDetail!cAcctNo) Then
                rsDetail.Delete
            ElseIf Trim(rsDetail!cAcctNo) = "" Then
                rsDetail.Delete
            Else
                rsDetail.MoveNext
            End If
        Else
            rsDetail.MoveNext
        End If
    Loop
    If rsLoanTD.RecordCount <> 0 Then rsLoanTD.MoveFirst
    Do Until rsLoanTD.EOF
        If rsLoanTD.Status = (adRecNew) Or rsLoanTD.Status = (adRecModified) Then
            If IsNull(rsLoanTD!cLoanTDNo) Then
                rsLoanTD.Delete
            ElseIf Trim(rsLoanTD!cLoanTDNo) = "" Then
                rsLoanTD.Delete
            Else
                rsLoanTD.MoveNext
            End If
        Else
            rsLoanTD.MoveNext
        End If
    Loop

    GetChild

End Function

'Filter detail recordset to header's primary
Private Sub GetChild()
    rsDetail.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
    rsLoanTD.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
End Sub

'Sets the form if record number is zero
Private Sub RSZero()
    sbRS.Panels(1) = "Record: 0/0"
    sbRS.Panels(2) = ""
    sbRS.Panels(4) = ""
    sbRS.Panels(5) = ""

    Set dtgAR.DataSource = Nothing
    Set dtgTD.DataSource = Nothing
    dtgAR.Refresh
    dtgTD.Refresh

    Set FrmName = Me
    UnbindControls
    TextClearing
    FormLocking True
    If rsHeader.State = adStateOpen Then rsHeader.Close
    If rsDetail.State = adStateOpen Then rsDetail.Close
    If rsLoanTD.State = adStateOpen Then rsLoanTD.Close

    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True

    txtTranNo.Locked = False
    txtTranNo.SetFocus

    Mode = Find

End Sub

Sub SearchObj(lEnable As Boolean)
    dtbDate.Enabled = lEnable
    cmdPickClient.Enabled = lEnable
End Sub

'compute total adjustment
Sub TotalAmount()
On Error Resume Next

    If Mode <> AddNewEdit Then Exit Sub

    nAmount = 0

    Set rs = New Recordset
    Set rs = rsDetail.Clone
    rs.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
    Do Until rs.EOF
        nAmount = nAmount + IIf(IsNull(rs!nAmount), 0, rs!nAmount)
        rs.MoveNext
    Loop
    Set rs = Nothing

    Set rs = New Recordset
    Set rs = rsLoanTD.Clone
    rs.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
    Do Until rs.EOF
        nAmount = nAmount + IIf(IsNull(rs!nAmount), 0, rs!nAmount)
        rs.MoveNext
    Loop
    Set rs = Nothing

    rsHeader!nGross = nAmount

End Sub

Private Function GetSearchString() As String
On Error GoTo ErrorHandler
Dim sWhere As String

    GetSearchString = True

    If Trim$(txtTranNo.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cTranno LIKE '" & Trim$(txtTranNo.Text) & "%'"
    End If

    If Trim$(dtbDate.Text) <> "__/__/____" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " dDate LIKE '" & Trim$(dtbDate.Text) & "%'"
    End If
    
    If Trim$(txtCode.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cBankID LIKE '" & Trim$(txtCode.Text) & "%'"
    End If

    GetSearchString = Trim$(sWhere)

    Exit Function
ErrorHandler:
    GetSearchString = "ERROR"
End Function


'Change Transaction Number
Sub ChangeTranNo(strTranNo As String)
    GetChild
    rsHeader!cTranNo = strTranNo
    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        rsDetail!cTranNo = strTranNo
        rsDetail.MoveNext
    Loop
    If rsLoanTD.RecordCount <> 0 Then rsLoanTD.MoveFirst
    Do Until rsLoanTD.EOF
        rsLoanTD!cTranNo = strTranNo
        rsLoanTD.MoveNext
    Loop
    GetChild
End Sub

Private Sub cboTRType_Click()
    rsDetail!cType = cboTRType
End Sub

Private Sub cboTRType_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        If dtgAR.Col = 0 Then
            rsDetail!cType = cboTRType
            cboTRType.Visible = False
            dtgAR.Col = 1
            dtgAR.SetFocus
        End If
    ElseIf KeyCode = vbKeyEscape Then
        cboTRType.Visible = False
    End If
End Sub

Private Sub cboTRType_LostFocus()
    cboTRType.Visible = False
End Sub

Private Sub cboTDType_Click()
    rsLoanTD!cType = cboTDType
End Sub

Private Sub cboTDType_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        If dtgTD.Col = 0 Then
            rsLoanTD!cType = cboTDType
            cboTDType.Visible = False
            dtgTD.Col = 1
            dtgTD.SetFocus
        End If
    ElseIf KeyCode = vbKeyEscape Then
        cboTDType.Visible = False
    End If
End Sub

Private Sub cboTDType_LostFocus()
    cboTDType.Visible = False
End Sub

Sub UpdateLoanTD()
Dim rsTD As Recordset
    Set rsTD = New Recordset
    Set rsTD = rsLoanTD.Clone
    rsTD.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
    rsTD.MoveFirst
    Do Until rsTD.EOF
        If rsTD!cType = "TTD" Then
'            cn.Execute ("UPDATE LOANTD SET nPaid = nPaid + " & rsTD!nAmount & ", " & _
'            "nBalance = nBalance - " & rsTD!nAmount & " WHERE cLoanTDNo = '" & Trim(rsTD!cLoanTDNo) & "' AND cCompanyID = '" & COID & "'")
        ElseIf rsTD!cType = "INT" Then
'            cn.Execute ("UPDATE LOANTD SET nInterest = nInterest + " & rsTD!nAmount & ", " & _
'            " WHERE cLoanTDNo = '" & Trim(rsTD!cLoanTDNo) & "' AND cCompanyID = '" & COID & "'")
        ElseIf rsTD!cType = "LRL" Then
            InsertLoan
        End If
        rsTD.MoveNext
    Loop
    Set rsTD = Nothing
End Sub


Sub InsertLoan()
Dim cmdInsertLoan As ADODB.Command
    Set cmdInsertLoan = New ADODB.Command
    With cmdInsertLoan
        .ActiveConnection = cn
        .CommandTimeout = 1000
        .CommandText = "SP_InsertLoan"
        .CommandType = adCmdStoredProc
        .Parameters("@cCompanyID") = COID
        .Parameters("@cTranNo") = Trim(txtTranNo)
        .Execute
    End With
    Set cmdInsertLoan = Nothing
End Sub

'Public Sub ShowForm(sTranNo As String)
'    If Mode = Find Then
'
'        OpenNewConnection connHeader
'        OpenNewConnection connDetail
'        OpenNewConnection connLoanTD
'
'        Set rsHeader = Nothing
'        Set rsDetail = Nothing
'        Set rsLoanTD = Nothing
'        Set rsHeader = New ADODB.Recordset
'        Set rsDetail = New ADODB.Recordset
'        Set rsLoanTD = New ADODB.Recordset
'
'        OpenRecordsetWithCN rsDetail, "*", "CREDIT_CMDM", connDetail, "WHERE cTranNo = '" & Trim(sTranNo) & "'"
'        OpenRecordsetWithCN rsLoanTD, "*", "CREDIT_LOANTD", connLoanTD, "WHERE cTranNo = '" & Trim(sTranNo) & "'"
'        OpenRecordsetWithCN rsHeader, "*", "CREDIT", connHeader, "WHERE cTranNo = '" & Trim(sTranNo) & "'"
'
'        If rsHeader.RecordCount = 0 Then
'            FormWaitHide
'            MsgBox "No matching record/s found.", vbInformation, "ComUnion Search"
'            RSZero
'            FormSearch True
'            SearchObj True
'            Mode = Find
'            Exit Sub
'        End If
'            SetDataSource
'            SetDataField
'            txtTranNo.BackColor = &HE0FFFF
'            Mode = Normal
'            oBar.BitEnabled Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , , , , True, True, , True, True
'
'    End If
'End Sub
'
'
